function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { memo, useCallback } from 'react';
import { Table, TableSelectionModel } from "../../../../functionalComponent";
import { Layout, iup } from "../../../../util";
import { QueryPanel } from "../../../query-panel";
import { loadSourceData } from "../../service";
import NoticeIconContent from "./NoticeIconContent";
/**
 * 默认单选、多选表格
 * table
 */
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var SourceTable = function SourceTable(props) {
  var getRef = props.getRef,
    state = props.state,
    popupMode = props.popupMode,
    flowCode = props.flowCode,
    busData = props.busData,
    rowDisable = props.rowDisable,
    iconVisible = props.iconVisible,
    onDataLoad = props.onDataLoad;

  // 表格数据data
  var tableRequest = useCallback(function (defaultParams) {
    var sourceId = state.sourceId;
    var newsourceId = sourceId !== null && sourceId !== void 0 && sourceId.indexOf('_') ? iup.split(sourceId, '_')[1] : sourceId;
    return loadSourceData(_objectSpread(_objectSpread({
      flowCode: flowCode,
      busData: busData
    }, defaultParams), {}, {
      popupMode: popupMode,
      sourceId: newsourceId
    }));
  }, [popupMode, state.sourceId]);

  // 搜索框
  var onSearch = function onSearch(_, queryCondition) {
    var _getRef;
    (_getRef = getRef('table')) === null || _getRef === void 0 || (_getRef = _getRef.current) === null || _getRef === void 0 || _getRef.getApi().setExtraParam({
      queryCondition: queryCondition
    });
  };
  return /*#__PURE__*/_jsxs(Layout.Flex, {
    direction: "column",
    style: {
      height: '100%'
    },
    children: [state.queryItems.length > 0 && /*#__PURE__*/_jsx(QueryPanel, {
      items: state.queryItems,
      onSearch: onSearch
    }), /*#__PURE__*/_jsx(NoticeIconContent, {
      iconVisible: iconVisible,
      children: /*#__PURE__*/_jsx(Table, {
        showRowNumber: true,
        columns: state.columns,
        ref: getRef('table'),
        autoLoad: true,
        request: tableRequest,
        pagination: {
          hideOnSinglePage: false
        },
        rowSelection: {
          type: state.allowMultiSelect == 1 ? [TableSelectionModel.MULTIPLE_INTERVAL, TableSelectionModel.CHECKBOX] : TableSelectionModel.ROW,
          disabled: rowDisable
        },
        onDataLoad: onDataLoad
      }, state.sourceId)
    })]
  });
};
export default /*#__PURE__*/memo(SourceTable);